var should = require('should');
var marketHandler = require('../../../app/servers/user/handler/marketHandler');
var config = require('../../config');
var configUtil = require('../../../app/util/configUtil');
var analyze = require('kc-analyze');

suite('测试marketHandler', function () {
    setup(function (done) {
        var analyze_config = configUtil.load('analyze');
        var game_config = configUtil.load('game');
        analyze.initialize({
            host: analyze_config.host,
            server_id: game_config.server_id
        });
        done();
    });

    suite('call list()', function () {
        test('市场：查询', function (done) {
            var msg = {};
            var session = {
                uid: config.role_id
            };

            var market_Handler = new marketHandler();
            market_Handler.list(msg, session, function (err, res) {
                // console.log('res:',JSON.stringify(res));
                done();
            });
        });
    });

    suite('call refresh()', function () {
        test('市场：刷新', function (done) {
            var msg = {};
            var session = {
                uid: config.role_id
            };

            var market_Handler = new marketHandler();
            market_Handler.refresh(msg, session, function (err, res) {
                // console.log('res:',res);
                // console.log('market_list:',res.result.market_list);
                done();
            });
        });
    });

    suite('call buy()', function () {
        test('市场：购买', function (done) {
            var msg = {
                market_pos: 3
            };
            var session = {};
            session.uid = config.role_id;

            var market_Handler = new marketHandler();
            market_Handler.buy(msg, session, function (err, res) {
                // console.log('res:',res);
                done();
            });
        });
    });
});
